package com.bibrApp.difu.actvity.account_info_mvp;

import android.content.Context;
import android.util.Log;

import com.bibrApp.difu.api.RetrofitNet;
import com.bibrApp.difu.base.BasePresenter;
import com.bibrApp.difu.utils.EncryptUtils;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

public class AccountInfoPresenter extends BasePresenter<IAccountInfoView> {
    public AccountInfoPresenter(Context context, IAccountInfoView iView) {
        super(context, iView);
    }

    public void loginOutP(String userId) {
        Map<String,String> map = new HashMap<>(1);
        map.put("userId",userId);
        RetrofitNet.getInstance().getApi()
                .loginout(EncryptUtils.encryptNewType(map))
                .compose(getActivityLifecycleProvider().bindToLifecycle())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(o -> {
                    if (o != null) {
                        if(o.getCode() == 200){
                            iView.success("退出成功");
                        }else{
                            iView.success("服务器异常");
                        }
                    }
                },throwable -> {
                    iView.success("服务器异常");
                    Log.d("dj",throwable.getMessage());
                });

    }
}
